<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
	<link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../js/startmove.js"></script>
	<script type="text/javascript" src="../../js/jquery-1.9.1.js"></script>
	<title>注册</title>
</head>
<body>
<div class="container-fluid">
	<div class="row">
		<div id="login_ajax">
			<div class="col-xs-12">
				<div class="user-picture">
					<a href="javascript:;">
						<img src="">
					</a>
					<p>未登录</p>
				</div>
			</div>
			<div class="col-xs-12">
				<div class="login-box">
					<div class="col-xs-3">
						用户状态
					</div>
					<div class="col-xs-9">

					</div>
				</div>
			</div>
		</div>
		<div class="col-xs-12">
			<div class="login-box">
				<div class="col-xs-3">
					到期时间
				</div>
				<div class="col-xs-9">
					2012-10-24
				</div>
			</div>
		</div>
		<div class="col-xs-12 login-class">
			<div class="col-xs-3"><a href="index.html">登陆</a></div>
			<div class="col-xs-3"><a href="recharge.html">充值</a></div>
			<div class="col-xs-3"><a href="query.html">查询</a></div>
			<div class="col-xs-3"><a href="register.html" class="active">注册</a></div>
		</div>
		<div class="col-xs-12" id="formInput">
			<div class="login-main">
				<div class="cos_row">
					 <span class="cos_row_span">
						   昵称：<b class="error_text">昵称不能为空</b>
					 </span>
					<input type="text" name="nickname">
				</div>
				<div class="cos_row">
					 <span class="cos_row_span">
						   账号：<b class="error_text">账号不能为空</b>
					 </span>
					<input type="text" name="account">
				</div>
             	<div class="cos_row">
					 <span class="cos_row_span">
						   密码：<b class="error_text">密码不能为空</b>
					 </span>
					<input type="password" name="password">
				</div>
				<div class="cos_row">
					 <span class="cos_row_span">
						   确认密码：<b class="error_text">昵称不能为空</b>
					 </span>
					<input type="password" name="rep_password">
				</div>
				<div class="cos_submit">
					<input type="submit" value="注册" onclick="register()" class="cos_submit">
				</div>
			</div>
		</div>
	</div>
	<footer>
		<div class="col-xs-3 col-xs-offset-2">
			<a href="index.html" class="btn_1_yes"></a>
		</div>
		<div class="col-xs-3">
			<a href="../game/index.html" class="btn_2"></a>
		</div>
		<div class="col-xs-3">
			<a href="../set/index.html" class="btn_3"></a>
		</div>
	</footer>
</div>
</body>
</html>
<script type="text/javascript" src="../../js/FromregisterCheck.js"></script>
<script>
	loginState();
	// s判断登录状态
	function loginState(){
		var indexUrl = "http://aaa.57810.mom/index.php/Index/index";
		$.ajax({
			type : "get",
			url : indexUrl,
			dataType : "jsonp",
			jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
			jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
			success : function(json){
				if(json['isLogin']!=false){
					// 变更dom
					var login = document.getElementById('login_ajax');
					html = '<div class="col-xs-12"><div class="user-picture"><a href="javascript:;"><img src=""></a><p>'+json['nickname']+'</p></div></div><div class="col-xs-12"><div class="login-box"><div class="col-xs-3">用户状态</div>' ;
					if(json['userType']=="USER_TYPE_NORMAL") {
						html += '<div class="col-xs-9">普通</div></div></div>';
					}
					if(json['userType']=="USER_TYPE_vip") {
						html += '<div class="col-xs-9">vip</div></div></div>';
					}
					login.innerHTML = html;
				}
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
				alert(errorThrown);
			}
		});

	}

	// s判断登录状态
	function register() {
		var indexUrl = "http://aaa.57810.mom/index.php/Index/register_do";
		var formInput = document.getElementById('formInput').getElementsByTagName('input');
		if(checkFrom(formInput)==false) { creatLayout("注册信息不能为空") ; return ;}
		data = {nickname:formInput[0].value,account:formInput[1].value,password:formInput[2].value};
		$.ajax({
			type: "get",
			url: indexUrl,
			dataType: "jsonp",
			data:data,
			jsonp: "callback",//传递给请求处理程序或页面的，用以获得jsonp回调函数名的参数名(默认为:callback)
			jsonpCallback: "success_jsonpCallback",//自定义的jsonp回调函数名称，默认为jQuery自动生成的随机函数名
			success: function (json) {
				console.log(json);
				if(json['code'] == 200){
					  window.location.reload();
				}else{
					  creatLayout("用户名重复了哦");
				}
			},
			error:function(XMLHttpRequest, textStatus, errorThrown){
				alert(XMLHttpRequest.status);
				alert(XMLHttpRequest.readyState);
				alert(textStatus);
				alert(errorThrown);
			}
		});
	}
</script>